import React, { Component } from 'react';

class Errorboundary extends Component {
    state={
        hasError:false
    }
    static getDerivedStateFromError(){
        return{
            hasError:true
        }
    }
    render() {
        if(this.state.hasError){
            return <div>Error</div>
        }
        return this.props.children
    }
    componentDidCatch(error,errorInfo){
        console.log(error);
        console.log(errorInfo);
    }
}

export default Errorboundary;
